
#region

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web.Mvc;
using Should;
using UserStoryTrackerDemo.Controllers;
using UserStoryTrackerDemo.Data;
using UserStoryTrackerDemo.Domain.Pocos;
using UserStoryTrackerDemo.Specs.Steps.Watin;

#endregion

namespace UserStoryTrackerDemo.Specs.Steps
{
	public class UserStoryStepsBase
	{
		public ViewResult NavigateToListPage()
		{
			var result =
				(ViewResult) new UserStoriesController(new Repository<UserStory>(new List<UserStory>(new List<UserStory>()
				                                                                                     	{
				                                                                                     		new UserStory()
				                                                                                     			{
				                                                                                     				Id = 1,
				                                                                                     				AsA = "Developer",
				                                                                                     				ICan = "test this page",
				                                                                                     				SoThatBecause =
				                                                                                     					"I can see it work",
				                                                                                     				Completed = false,
				                                                                                     			},
				                                                                                     		new UserStory()
				                                                                                     			{
				                                                                                     				Id = 2,
				                                                                                     				AsA = "Developer",
				                                                                                     				ICan =
				                                                                                     					"test this repository",
				                                                                                     				SoThatBecause =
				                                                                                     					"I can see it return data",
				                                                                                     				Completed = false,
				                                                                                     			},
				                                                                                     	}))).Index();
			//Try to add watin stuff here
			var rootUrl = new Uri(ConfigurationManager.AppSettings["RootUrl"]);
			var absoluteUrl = new Uri(rootUrl, "/UserStories");
			WebBrowser.Current.GoTo(absoluteUrl);

			return result;
		}

		public void ShouldBeOnListPage(ViewResult result)
		{
			result.ShouldNotBeNull();
			WebBrowser.Current.Title.ShouldContain("User Stories");
		}
	}
}